package com.acme.bankapp.app;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.acme.bankapp.server.BankServer;
import com.acme.domain.account.*;
import com.acme.domain.bank.*;
import com.acme.exceptions.BankException;
import com.acme.service.bank.BankService;

public class BankApplication {
	private static Bank db = new Bank();
	static BankServer bs = new BankServer(db);
	public static void main(String[] args) {
		
		try {
			BankService.loadClients(db, "clients.txt");
		} catch (NumberFormatException|BankException|IOException e) {
			e.printStackTrace();
		}
		
		List<Account> accounts = new ArrayList<Account>();
		accounts.add(new CheckingAccount(20, 30));
		Client clientPetrova = new Client(accounts, "Petrova", Gender.FEMALE);

		try {
			BankService.addClient(db, clientPetrova);
		} catch (BankException e) {
			e.printStackTrace();
		}
		
		try {
			bs.start(1234);
		} catch (ClassNotFoundException | IOException | BankException e) {
			e.printStackTrace();
		}
		
	}
}

